//
//  SRModifyPersonalSexView.m
//  SportRing
//
//  Created by icelee on 14-10-31.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRModifyPersonalSexView.h"

#import "SRDB.h"

@interface SRModifyPersonalSexView()

@property (nonatomic, weak)IBOutlet LGButton *maleButton;
@property (nonatomic, weak)IBOutlet LGButton *femaleButton;
@property (nonatomic, weak)IBOutlet UIImageView *selectedMaleImageView;
@property (nonatomic, weak)IBOutlet UIImageView *selectedFemaleImageView;

@end

@implementation SRModifyPersonalSexView

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    self.selectedMaleImageView.hidden = YES;
    self.selectedFemaleImageView.hidden = YES;
}

- (void)setSexType:(SR_SEX_TYPE)sexType
{
    if (_sexType == sexType) {
        return;
    }
    _sexType = sexType;
    [[SRMe currentUser] configAttributesWithBlock:^(SRMe *meSelf) {
        meSelf.gender = @(_sexType);
    }];
    
    [self switchSex:_sexType];
}

- (void)switchSex:(SR_SEX_TYPE)type
{
    if (type == SR_SEX_TYPE_MALE)
    {
        self.selectedMaleImageView.hidden = NO;
        self.selectedFemaleImageView.hidden = YES;
        
    }
    
    if (type == SR_SEX_TYPE_FAMALE)
    {
        self.selectedMaleImageView.hidden = YES;
        self.selectedFemaleImageView.hidden = NO;
        
    }
}

+ (SRModifyPersonalSexView*)LoadSRModifyPersonalSexView
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SRModifyPersonalSexView" owner:self options:nil];
    
    return [nib objectAtIndex:0];
}

- (IBAction)maleButtonClicked:(id)sender
{
    self.sexType = SR_SEX_TYPE_MALE;
    
}

- (IBAction)femaleButtonClicked:(id)sender
{
    
    self.sexType = SR_SEX_TYPE_FAMALE;
    
}

@end
